package com.ln.design.mode.singleton;

/**
 * 双重校验锁
 * 这个是{@link LazySafeSingleton}的升级版，俗称双重检查锁定，详细介绍请查看：
 *
 * @Author zhangj
 * @Date 2022/12/2 00:03
 */
public class DoubleCheckSingleton {

    private volatile static DoubleCheckSingleton singleton;

    private DoubleCheckSingleton() {
    }

    public static DoubleCheckSingleton getSingleton() {
        if (singleton == null) {
            synchronized (DoubleCheckSingleton.class) {
                if (singleton == null) {
                    singleton = new DoubleCheckSingleton();
                }
            }
        }
        return singleton;
    }

}
